<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #box{
            width: 200px;
            height: 200px;
            border: 1px solid black;
        }
    </style>
</head>
<body>
    <input type="text">
    <button id="btn">点击</button>
    <div id="box">
        <h1>嘿嘿嘿</h1>
        <p>呵呵呵呵</p>
        <ul>
            <li>哈哈</li>
            <li>略略</li>
        </ul>
    </div>
    <script>
        const btn = document.getElementById('btn')
        const input = document.querySelector('input')
        const box = document.getElementById('box')

        btn.addEventListener('click',function(e){
            console.log(e);
            console.log(e.clientX);
            console.log(e.clientY);
        })
        input.addEventListener('keyup',function(e){
            console.log(e.key);  //打印出按下了哪个按键
            console.log(e.type);
        })
        box.addEventListener('click',function(e){
            // console.log('点击了box');
            // console.log(e.target.localName);
            let name = e.target.localName
            if(name === 'h1'){
                console.log('我也嘿嘿嘿');
            }else{
                console.log(name);
            }
        })

        document.addEventListener('contextmenu',function(e){
            e.preventDefault()
            console.log(e.type);
        })
    </script>
</body>
</html>